package _16define;

public class Demo3 {
    public static void main(String[] args) throws CloneNotSupportedException {
        Dog2 dog2 = new Dog2("大黄","yellow");
        Dog2 clone=dog2.clone();
        System.out.println(dog2);
        System.out.println(clone);


    }
}
class Dog2 implements Cloneable{
    String name;
    String color;

    public Dog2(String name, String color) {
        this.name = name;
        this.color = color;
    }

    @Override
    public Dog2 clone() throws CloneNotSupportedException {
        Object clone=super.clone();
        Dog2 dog= (Dog2) clone;
        return dog;
    }

    @Override
    public String toString() {
        return "Dog2{" +
                "name='" + name + '\'' +
                ", color='" + color + '\'' +
                '}';
    }
}

